
/*------------------------------------------------------------------------------
	1. Housekeeping
------------------------------------------------------------------------------*/

	*Settings
		set more off
		pause off
		clear
	
	*Set Globals
		global data = "...\Data"
		global output = "...\Output\Tables"
		
/*------------------------------------------------------------------------------
	2. Create Table 1:
------------------------------------------------------------------------------*/	

import excel using "${data}\table_backup_data.xlsx", clear first sheet("claim_by_medicaid")

	foreach i of varlist perc_claimed*{
		replace `i' = `i'*100
	}

	foreach i of varlist perc_claimed*{
		mkmat `i', matrix(`i')
		mat `i' = `i''
	}

	cap program drop claim_dat

	program claim_dat, eclass
		*returned in e() structure
		foreach i of varlist perc_claimed*{
			eret mat `i' = `i'
		}
	end

	estimates clear
	eststo clear

	claim_dat
	
#delimit ;

esttab using "$output/child_claim_rate_by_medicaid.tex", replace
	booktabs nogaps label noobs collabels(none) nonumber eqlabels(none) nomtitles  substitute(.\\ \\)
	cells("perc_claimed (fmt(%10.1fc)) perc_claimed_mcaid (fmt(%10.1fc)) perc_claimed_no_mcaid (fmt(%10.1fc))") 
	prehead(\begin{table}[htbp]            
			\footnotesize   
			\caption{Child Claim Rate by Year and Medicaid Coverage}    
			\label{tab:medicaid}
			\makebox[\textwidth][c]{                
			\centering  
			\begin{tabular}{l*{3}{c}} 
			\toprule        
			& \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\
			\cmidrule(lr){2-4} 
			& \multicolumn{1}{c}{Overall} & \multicolumn{1}{c}{Medicaid} & \multicolumn{1}{c}{Non-Medicaid} \\
			\midrule) 
	varl(r1 "2017"
	   	 r2 "2018"
	     r3 "2019"
		 r4 "2020"
		 r5 "2021")
	postfoot(\midrule                  
			\multicolumn{4}{p{2in}}{\footnotesize{\emph{Notes:"The table reports the estimated child claim rate by year separately for children appearing on a Form 1095 for Medicaid or CHIP (Column 2) versus other forms of health insurance (Column 3). Column 1 reports the child claim rate for children appearing on any Form 1095, and is identical to our baseline child claim rate estimates reported in Column 2 of Table "} }}        
			\end{tabular}}
			\end{table}
			

#delimit cr